import Vue from 'vue'
import Router from 'vue-router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

Vue.use(Router)
Vue.use(ElementUI)

import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/register',
    component: () => import('@/views/login/register'),
    hidden: true
  },
  {
    path: '/auth-redirect',
    component: () => import('@/views/login/auth-redirect'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/error-page/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error-page/401'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/dashboard/index'),
        name: 'Dashboard',
        meta: { title: 'Dashboard', icon: 'dashboard', affix: true }
      }
    ]
  },
  {
    path: '/profile',
    component: Layout,
    redirect: '/profile/index',
    hidden: true,
    children: [
      {
        path: 'index',
        component: () => import('@/views/profile/index'),
        name: 'Profile',
        meta: { title: 'Profile', icon: 'user', noCache: true }
      }
    ]
  }
]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [
  /* {
    path: 'es',
    component: () => import('@/views/wish/fangyuan/HousePicture'),
    name: 'Es',
    meta: {
      title: 'es全量同步'
      // if do not set roles, means: this page does not require permission
    }
  },*/
  /* {
    path: '/sys',
    component: Layout,
    redirect: '/sys/user',
    alwaysShow: true, // will always show the root menu
    name: 'Sys',
    meta: {
      title: '系统管理',
      icon: 'lock',
      roles: ['admin', 'editor'] // you can set roles in root nav
    },
    children: [
      {
        path: 'es',
        component: () => import('@/views/sys/es'),
        name: 'Es',
        meta: {
          title: 'es全量同步'
          // if do not set roles, means: this page does not require permission
        }
      },
      {
        path: 'user',
        component: () => import('@/views/sys/user/user'),

        name: 'User',
        meta: {
          title: '人员管理'
          // if do not set roles, means: this page does not require permission
        }
      },
      {
        path: 'dept',
        component: () => import('@/views/sys/dept'),
        name: 'Dept',
        meta: {
          title: '部门管理'
          // if do not set roles, means: this page does not require permission
        }
      },
      {
        path: 'add',
        component: () => import('@/views/sys/user/add'),
        name: 'Add'

      },
      {
        path: 'update',
        component: () => import('@/views/sys/user/update'),
        name: 'Update'

      },
      {
        path: 'role',
        component: () => import('@/views/sys/role'),
        name: 'Role',
        meta: {
          title: '角色管理'
          // if do not set roles, means: this page does not require permission
        }
      },
      {
        path: 'business',
        component: () => import('@/views/sys/business/business'),
        name: 'Business',
        meta: {
          title: '商户管理'
          // if do not set roles, means: this page does not require permission
        }
      },
      {
        path: 'menu',
        component: () => import('@/views/sys/menu/menu'),
        name: 'Menu',
        meta: {
          title: '菜单管理'
          // if do not set roles, means: this page does not require permission
        }
      },
      {
        path: 'businessreview',
        component: () => import('@/views/sys/business/businessReview'),
        name: 'Businessreview'
      },
      {
        path: 'menuadd',
        component: () => import('@/views/sys/menu/menuadd'),
        name: 'menuadd'
      },
      {
        path: 'menuupdate',
        component: () => import('@/views/sys/menu/menuupdate'),
        name: 'menuupdate'
      },
      {
        path: 'sql',
        component: () => import('@/views/sys/sql'),
        name: 'Sql',
        meta: {
          title: 'SQL监控'
          // if do not set roles, means: this page does not require permission
        }
      },
      {
        path: 'log',
        component: () => import('@/views/sys/log'),
        name: 'Log',
        meta: {
          title: '系统日志'
          // if do not set roles, means: this page does not require permission
        }
      },
      {
        path: 'interface',
        component: () => import('@/views/sys/interface'),
        name: 'Interface',
        meta: {
          title: '接口管理'
          // if do not set roles, means: this page does not require permission
        }
      }
      // {
      //   path: 'yuyue',
      //   component: () => import('@/views/sys/yuyue'),
      //   name: 'Yuyue',
      //   meta: {
      //     title: '预约看房列表'
      //     // if do not set roles, means: this page does not require permission
      //   }
      // }
    ]
  },
  {
<<<<<<< HEAD
    path: '/shoufang',
    component: Layout,
    redirect: '/',
    alwaysShow: true, // will always show the root menu
    name: 'Shoufang',
    meta: {
      title: '收房管理',
      icon: 'lock',
=======
    path: '/yuyue',
    component: Layout,
    redirect: '/sys/user',
    alwaysShow: true, // will always show the root menu
    name: 'Fangyuan',
    meta: {
      title: '房源管理',
      icon: 'el-icon-s-home',
>>>>>>> 606d7f0675595d86e011dbcde78949ba25b63ddc
      roles: ['admin', 'editor'] // you can set roles in root nav
    },
    children: [
      {
<<<<<<< HEAD
        path: 'owners',
        component: () => import('@/views/shoufang/owners'),
        name: 'Owners',
        meta: {
          title: '业主管理'
          // if do not set roles, means: this page does not require permission
        }
      },
      {
        path: 'shoufang',
        component: () => import('@/views/shoufang/shoufang'),
        name: 'Shoufang',
        meta: {
          title: '收房合同查询'
          // if do not set roles, means: this page does not require permission
        }
      },
      {
        path: 'jieyue',
        component: () => import('@/views/shoufang/jieyue'),
        name: 'Jieyue',
        meta: {
          title: '解约协议查询'
          // if do not set roles, means: this page does not require permission
        }
      },
      {
        path: 'sfadd',
        component: () => import('@/views/shoufang/sfadd'),
        name: 'Sfadd',
        meta: {
          title: '收房合同录入'
          // if do not set roles, means: this page does not require permission
        }
      },
      {
        path: 'sfxy',
        component: () => import('@/views/shoufang/sfxy'),
        name: 'Sfxy',
        meta: {
          title: '收房合同续约'
          // if do not set roles, means: this page does not require permission
        }
      },
      {
        path: 'jyadd',
        component: () => import('@/views/shoufang/jyadd'),
        name: 'Jyadd',
        meta: {
          title: '解约合同录入'
          // if do not set roles, means: this page does not require permission
        }
      }
    ]
  },
  {
    path: '/caiwu',
    component: Layout,
    redirect: '/',
    alwaysShow: true, // will always show the root menu
    name: 'Caiwu',
    meta: {
      title: '财务管理',
      icon: 'lock',
      roles: ['admin', 'editor'] // you can set roles in root nav
    },
    children: [
      {
        path: 'caiwu',
        component: () => import('@/views/caiwu/caiwu'),
        name: 'Caiwu',
        meta: {
          title: '财务报表'
          // if do not set roles, means: this page does not require permission
        }
      }
    ]
  }
=======
        path: 'yuyue',
        component: () => import('@/views/sys/yuyue'),
        name: 'Yuyue',
        meta: {
          title: '预约看房列表'
          // if do not set roles, means: this page does not require permission
        }
      }
    ]
  },{
    path: '/house',
    component: Layout,
    redirect: '/house',
    meta: {
      title: '房源管理',
      icon: 'el-icon-office-building'
    },
    children: [
      {
        path: '/modules/sys/roomStatusMap',
        component: () => import('@/views/propertyManagement/Cancellationofrent/roomStatusMap.vue'),
        name: 'roomStatusMap',
        meta: { title: '房态图', icon: 'el-icon-picture-outline-round', affix: true },
      },
      {
        path: '/modules/sys/contract',
        component: () => import('@/views/propertyManagement/TenantManagement/contract.vue'),
        name: 'contract',
        meta: {title: '租客管理', icon: 'el-icon-user-solid', affix: true},
      }
      ,
      {
        path: '/modules/sys/inputConcentrated',
        component: () => import('@/views/propertyManagement/inputConcentrated.vue'),
        name: 'inputConcentrated',
        meta: { title: '添加集中式房源', icon: 'el-icon-user-solid', affix: true },
      },

      {
        path: '/modules/sys/inputDistributed',
        component: () => import('@/views/propertyManagement/inputDistributed.vue'),
        name: 'inputDistributed',
        meta: { title: '添加分散式房源', icon: 'el-icon-user-solid', affix: true },
      },

      {
        path: '/modules/sys/contractht',
        component: () => import('@/views/propertyManagement/Rentalcontract/contractht.vue'),
        name: 'contractht',
        meta: { title: '租房合同查询', icon: 'el-icon-s-order', affix: true },
      },
      {
        path: '/modules/sys/contracthtInsert',
        component: () => import('@/views/propertyManagement/Rentalcontract/contracthtInsert.vue'),
        name: 'contracthtInsert',
        meta: { title: '租房合同录入', icon: 'el-icon-tickets', affix: true },
      },
      {
        path: '/modules/sys/contracthtRenew',
        component: () => import('@/views/propertyManagement/Rentalcontract/contracthtRenew.vue'),
        name: 'contracthtRenew',
        meta: { title: '租房合同续约', icon: 'el-icon-document-checked', affix: true },
      } ,
      {
        path: '/modules/sys/contracthtjyInsert',
        component: () => import('@/views/propertyManagement/Cancellationofrent/contracthtjyInsert.vue'),
        name: 'contracthtjyInsert',
        meta: { title: '租房解约合同录入', icon: 'el-icon-document-delete', affix: true },
      }
      ,
      {
        path: '/modules/sys/contracthtjy',
        component: () => import('@/views/propertyManagement/Cancellationofrent/contracthtjy.vue'),
        name: 'contracthtjy',
        meta: { title: '租房解约查询', icon: 'el-icon-document', affix: true },
      }

    ]
  }, {
    path: '/shouFang',
    component: Layout,
    redirect: '/shouFang',
    meta: {
      title: '收房管理',
      icon: 'el-icon-office-building'
    },
    children: [
      {
        path: '/modules/sys/housingContractInput',
        component: () => import('@/views/housingContractManagement/housingContractInput.vue'),
        name: 'housingContractInput',
        meta: { title: '收房合同录入', icon: 'el-icon-picture-outline-round', affix: true },
      },
      {
        path: '/modules/sys/housingContractRenew',
        component: () => import('@/views/housingContractManagement/housingContractRenew.vue'),
        name: 'housingContractRenew',
        meta: { title: '收房合同续约', icon: 'el-icon-picture-outline-round', affix: true },
      },
      {
        path: '/modules/sys/housingContractSearch',
        component: () => import('@/views/housingContractManagement/housingContractSearch.vue'),
        name: 'housingContractSearch',
        meta: { title: '收房合同查询', icon: 'el-icon-picture-outline-round', affix: true },
      },
      {
        path: '/modules/sys/terminationAgreementInput',
        component: () => import('@/views/housingContractManagement/terminationAgreementInput.vue'),
        name: 'terminationAgreementInput',
        meta: { title: '解约合同录入', icon: 'el-icon-picture-outline-round', affix: true },
      },
      {
        path: '/modules/sys/terminationAgreementSearch',
        component: () => import('@/views/housingContractManagement/terminationAgreementSearch.vue'),
        name: 'terminationAgreementSearch',
        meta: { title: '解约合同查询', icon: 'el-icon-picture-outline-round', affix: true },
      },
      {
        path: '/modules/sys/ownerManagement',
        component: () => import('@/views/housingContractManagement/ownerManagement.vue'),
        name: 'ownerManagement',
        meta: { title: '业主管理', icon: 'el-icon-picture-outline-round', affix: true },
      }
    ]
  }*/

]
const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
